package com.zhuang.designpattern.flyweight;

import com.zhuang.designpattern.flyweight.util.Activity;
import com.zhuang.designpattern.flyweight.util.RedisUtils;

/**
 * description: ActivityController
 * date: 2022/9/18 19:57
 * author: Zhuang
 * version: 1.0
 */
public class ActivityController {
    private final RedisUtils redisUtils = new RedisUtils();

    public Activity queryActivityInfo(Long id) {
        Activity activity = ActivityFactory.getActivity(id);
        // 模拟从Redis中获取库存变化信息
        Stock stock = new Stock(1000, redisUtils.getStockUsed());
        activity.setStock(stock);
        return activity;
    }
}
